﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Alisoft.SIP
{
    public class SipStatus
    {
        private static Object locker = new Object();

        //ERROR( "error", 							"0000"),//服务请求失败
        //SUCCESS( "success", 						"9999"),//服务请求成功
        //SIGNATURE_INVALID( "signatureInvalid", 		"1001"),//签名无效
        //REQ_TIMEOUT( "reqTimeout", 					"1002"),//请求过期
        //BINDUSER_FAILD( "binduserFaild", 			"1003"),//用户绑定失败
        //NEED_BINDUSER( "needBinduser", 				"1004"),//需要绑定用户
        //NEED_APPKEY( "needAppKey", 					"1005"),//需要提供AppKey
        //NEED_APINAME( "needApiName", 				"1006"),//需要提供服务名
        //NEED_SIGN( "needSign", 						"1007"),//需要提供签名
        //NEED_TIMESTAMP( "needTimeStamp", 			"1008"),//需要提供时间戳
        //AUTH_FAILD( "authFaild", 					"1009"),//用户认证失败
        //NORIGHT_CALLSERVICE( "noRightCallService", 	"1010"),//无权访问服务
        //SERVICE_NOTEXIST( "serviceNotExist", 				"1011"),//服务不存在
        //NEED_SESSIONID( "needSessionid",				"1012"),//需要提供SessionId
        //NEED_USERNAME( "needUsername",					"1013"),//需要提供用户名
        //CALLBACK_API_NOTEXIST("callbackApiNotExist",    "1014"),//回调服务不存在
        //APPKEY_NOTEXIST("appKeyNotExist",               "1015"),//AppKey不存在
        //SERVICE_COUNTORFLOW_OUTOFLIMIT("serviceCountOrFlowOutOfLimit","1016"),//服务次数或流量超过限制
        //SERVICE_ACCESS_OUTOFFREQUENCYLIMIT("serviceAccessOutOfFrequencyLimit","1017"),//服务请求过于频繁
        //LOGIN_URL_TOOLONG("loginUrlTooLong","1018");//isv登陆地址过长

        private string v;

        private string c;

        private static Dictionary<string, SipStatus> status;

        SipStatus(string value, string code)
        {
            v = value;
            c = code;
        }


        public string Value
        {
            get
            {
                return v;
            }
        }

        public string Code
        {
            get
            {
                return c;
            }
        }

        public static SipStatus GetStatus(String code)
        {
            if (status == null)
            {
                InitStatusMap();
            }
            return status[code];
        }

        private static void InitStatusMap()
        {
            lock (locker)
            {
                if (status == null)
                {
                    status = new Dictionary<string, SipStatus>();
                }

                //for (SipStatus sipStatus : SipStatus.values()) {
                //    status.put(sipStatus.getCode(), sipStatus);
                //}
            }
        }
    }
}

